Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add document-level validator #157

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nkgentile
Copy link
Contributor

@nkgentile nkgentile commented Sep 26, 2023

Export a custom, document-level validation function that a user can register on their schema types:

import {defineType} from 'sanity'
import {referenceLanguageValidator} from '@sanity/document-internationalization'

export const article = defineType({
  title: 'Article',
  name: 'article',
  type: 'document',
  // ..rest of the schema definition
  validation: (rule) =>
    // You can decide whether this will trigger a warning
    // or an error in the Studio
    rule.custom(referenceLanguageValidator).warning(),
})
Screenshot 2023-09-26 at 4 11 54 PM

@nkgentile nkgentile changed the title feature/add document validation feat: add document-level validator Sep 26, 2023
@socket-security
Copy link

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@types/traverse 0.6.32 None +0 8.82 kB types
@sanity/icons 2.2.2...2.4.1 None +0/-0 1.15 MB sanity-io

🚮 Removed packages: @sanity/[email protected], [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant